package com.gitee.wsl.compose.mvi.ui.iconbutton

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.material3.IconButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.gitee.wsl.compose.mvi.component.InteractionSourceProjector
import com.gitee.wsl.compose.mvi.ui.icon.IconProjector


class IconButtonProjector(
    interactor: IconButtonInteractor,
    presenter: IconButtonPresenter = IconButtonPresenter.Default
) : InteractionSourceProjector<IconButtonInteractor, IconButtonPresenter>(interactor, presenter) {

    @Composable
    override fun body(
        combinedModifier: Modifier,
        interactor: IconButtonInteractor,
        presenter: IconButtonPresenter,
        interactionSource: MutableInteractionSource,
    ) {
        val iconProjector = IconProjector(interactor.icon, presenter.icon)

        IconButton(
            onClick = interactor.onClick,
            modifier = combinedModifier,
            enabled = interactor.enabled,
            interactionSource = interactionSource,
        ) {
            iconProjector()
        }
    }
}
